package com.example.yuanboot.controller.db;

import com.example.yuanboot.common.config.datasource.DataSourceHolder;
import com.example.yuanboot.common.msg.BaseResultCode;
import com.example.yuanboot.common.msg.ObjectRestResponse;
import com.example.yuanboot.common.msg.ResponseUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 切换数据库
 *
 * @author csp 2021-08-22
 */
@RestController
@RequestMapping("db")
@RequiredArgsConstructor
public class SwitchDbController {


    @PostMapping("switch")
    public ObjectRestResponse switchDb(String dbType) {
        DataSourceHolder.setDataSourceKey(dbType);
        return ResponseUtils.r(null, BaseResultCode.SUCCESS);
    }


}
